﻿using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Composition;

namespace Red.Scripts.Defines
{
    public enum Setting
    {
        IntellisenseTabBehaviour,
        AutocompleteOnSpace,
        HighlightMatchingWordBehaviour,
        SccSearchOrder,
        SccCustomSearchPath,
    }

    public enum IntellisenseTabBehaviour
    {
        SwitchCategory,
        Autocomplete
    }

    public enum HighlightMatchingWordBehaviour
    {
        Disabled,
        Global
    }

    public enum SccSearchOrder
    {
        [Description( "Package" )]
        Package,

        [Description( "Debug Dll" )]
        BinDebugDll,

        [Description( "Debug" )]
        BinDebug,

        [Description( "Release Dll" )]
        BinReleaseDll,

        [Description( "Release" )]
        BinRelease,

        [Description( "Final DLL" )]
        BinFinalDLL,


        [Description( "Final" )]
        BinFinal,

        [Description( "Engine Tools" )]
        EngineTools,

        [Description( "Custom Path" )]
        Custom,
    }

    [Export]
    public class Settings
    {
        #region Private Data

        private Dictionary<Setting, object> _settings = new Dictionary<Setting, object>();

        #endregion Private Data

        #region Properties

        public object this[ Setting option ]
        {
            get
            {
                object value;
                if ( _settings.TryGetValue( option, out value ) )
                {
                    return value;
                }

                return null;
            }

            set
            {
                _settings[ option ] = value;

                Changed?.Invoke( option, value );
            }
        }

        #endregion Properties

        #region Events

        public delegate void ChangedHandler( Setting setting, object value );
        public event ChangedHandler Changed;

        #endregion Events
    }
}
